//
//  ChooeseView.m
//  Project two framework
//
//  Created by rimi on 16/7/29.
//  Copyright © 2016年 张峥. All rights reserved.
//

#import "ChooeseView.h"
#import "SingleView.h"
#import "ZZConfig.h"
@implementation ChooeseView


+ (instancetype)showOtherView
{
    static ChooeseView *chooseView = nil;
    chooseView = [[ChooeseView alloc]init];
    return chooseView;
}

- (instancetype)init
{
    self = [super init];
    if (self) {
        [self addOtherView];
    }
    return self;
}

- (void)addOtherView
{
        [super addOtherView];
        [self.imageView addSubview:self.chooseBuy];
        [self.imageView addSubview:self.content];
        self.shoppingBtn.hidden = YES;
        [self.imageView addSubview:self.bottomView];
        [self.bottomView addSubview:self.redView];
        [self.redView addSubview:self.newsLabel];
        [self.redView addSubview:self.contents];
}
- (void)chooseBuyAction
{
    [SingleView showOtherView];
}

- (void)clooseRedView
{
    [UIView animateWithDuration:0.5 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{
        self.bottomView.transform = CGAffineTransformMakeScale(0.0001, 0.0001);
    } completion:^(BOOL finished) {
        [self.bottomView removeFromSuperview];
    }];

    
}

- (UIButton *)chooseBuy
{
    if (_chooseBuy == nil) {
        _chooseBuy = ({
            UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
            btn.frame = CGRectMake(CGRectGetMaxX(self.imageView.bounds) - 80, 70, 50, 30);
            [btn addTarget:self action:@selector(chooseBuyAction) forControlEvents:UIControlEventTouchUpInside];
            [btn setImage:[UIImage imageNamed:@"选购_03.png"] forState:UIControlStateNormal];
            btn;
        });
    }
    return _chooseBuy;
    
}

- (UILabel *)content
{
    if (_content == nil) {
        _content = ({
            UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(50, 100, CGRectGetWidth(self.imageView.frame) - 100, 50)];
            label.textAlignment = NSTextAlignmentLeft;
            label.font = [UIFont systemFontOfSize:14];
            label.numberOfLines = 0;
            label;
        });
    }
    return _content;
}



- (UIView *)redView
{
    if (_redView == nil) {
        _redView = ({
            UIView *view = [[UIView alloc]initWithFrame:CGRectMake(330, 200, 200, 200)];
            UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clooseRedView)];
            [view addGestureRecognizer:tap];
            view.backgroundColor = COLOR(125, 23, 26, 1);
            view;
        });
    }
    return _redView;
}



- (UILabel *)newsLabel
{
    if (_newsLabel == nil) {
        _newsLabel = ({
            UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.redView.frame), 40)];
            label.textAlignment = NSTextAlignmentCenter;
            label.font = [UIFont systemFontOfSize:18];
            label.textColor = [UIColor whiteColor];
            label.text = @"最新消息";
            label;
        });
    }
    return _newsLabel;
}


- (UILabel *)contents
{
    if (_contents == nil) {
        _contents = ({
            UILabel *label = [[UILabel alloc]init];
            label.textAlignment = NSTextAlignmentCenter;
            label.textColor = [UIColor whiteColor];
            label.font = [UIFont systemFontOfSize:16];
            label.numberOfLines = 0;
            label;
        });
    }
    return _contents;
}



@end
